//
//  FSWGetAppInfo.m
//  quhuolang
//
//  Created by 曹欣欣 on 2018/3/10.
//  Copyright © 2018年 fusw. All rights reserved.
//

#import "FSWGetAppInfo.h"
#import <SystemConfiguration/CaptiveNetwork.h>

@implementation FSWGetAppInfo

+ (void)getAppInfo
{
    
//    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    NSString *appVerion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
//    dict[@"Operation-System"] = @"IOS";
//    dict[@"Client-Version"] = appVerion;
//    dict[@"Client-Key"] = FSWCLIENT_KEY;
    [fUserDefaults setObject:appVerion forKey:CLINET_VERSION];
  
}

+ (NSString *)getAppInfoVersion
{
    NSString *appVerion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    return appVerion;
}

// 只能获取当前的SSID
+ (id)fetchSSIDInfo
{
    NSString *currentSSID = @"";
    CFArrayRef myArray = CNCopySupportedInterfaces();
    if (myArray != nil){
        NSDictionary* myDict = (__bridge NSDictionary *) CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
        if (myDict!=nil){
            currentSSID=[myDict valueForKey:@"SSID"];
        } else {
            currentSSID=@"<<NONE>>";
        }
    } else {
        currentSSID=@"<<NONE>>";
    }
    
    NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
    NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
    id info = nil;
    for (NSString *ifnam in ifs) {
        info = (__bridge id)CNCopyCurrentNetworkInfo((CFStringRef)CFBridgingRetain(ifnam));
        if (info && [info count]) {
            break;
        }
    }
    
    
    return info;
}


@end
